<?php
include '../config/auth.php';
function success($res){
    $result = [
        'error'=>0,
        'message'=>$res,
    ];
    return json_encode($result);
}

function error($msg){
    $data = [
        'error'=>1,
        'message'=>$msg
    ];
    return json_encode($data);
}


try {
    $db = new PDO('mysql:host=120.77.37.81;dbname=onlinechat','root','123456');
    $statement=$db->prepare('SELECT `user`.nickname,`user`.path from user_room LEFT JOIN 
                            `user` ON `user`.username=user_room.user_name WHERE room_id=:room_id;');
    $statement->execute([':room_id'=> $_GET['id']]);
    $result=$statement->fetchAll();

} catch (PDOException $e) {
    die('程序出错');
}

echo success($result);